package cn.schoolwow.util.test.module.query.instanceList.flow.query;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.domain.query.instanceList.QueryInstanceList;
import cn.schoolwow.util.test.module.common.domain.User;
import org.junit.Assert;

import java.util.ArrayList;
import java.util.List;

public class InstanceQueryNotInFieldFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        List<User> userList = (List<User>) flowContext.checkData("userList");

        List<String> usernameList = new ArrayList<>();
        for(int i=0;i<5;i++){
            usernameList.add("username"+i);
        }
        List<String> filterUserNameList = QueryInstanceList.newQuery(userList)
                .addNotInQuery("username", usernameList)
                .execute()
                .getSingleFieldValueList("username");
        Assert.assertEquals(5, filterUserNameList.size());
        for(int i=5;i<10;i++){
            Assert.assertTrue(filterUserNameList.contains("username"+i));
        }
    }

    @Override
    public String name() {
        return "用户实例NotIn查询条件测试";
    }
}
